//测试游戏逻辑

#include"game.h"
#include"game.c"

void menu()
{
    printf("**************\n");
    printf("*****MENU*****\n");
    printf("****1 PLAY****\n");
    printf("****0 EXIT****\n");
    printf("**************\n");
}

void game()
{
    //存储数据-二维数组
    //用头文件数据,方便后面改进游戏
    char board[ROW][COL];
    //初始化棋盘-初始化空格
    InitBoard(board,ROW,COL);

    //打印棋盘
    DisplayBoard(board,ROW,COL);

    //实现游戏逻辑
    int  ret = 0;//接收返回Is_win返回值,判断输赢
    while(1)
    {
        //玩家回合
        int x=0;
        int y=0;
        Player_Move(board,ROW,COL);

        //判断输赢
        ret = Return_IsWin(board,ROW,COL);
        if (ret != 3)
        {
            break;
        }
        
        //电脑回合
        int t=(unsigned int)time(NULL);
        Computer_Move(board,ROW,COL,t);
        
        ret = Return_IsWin(board,ROW,COL);
        if (ret != 3)
        {
            break;
        }

    }
    int lucky=0;
    IsWin(ret,lucky);

    system("cls");
}


int main()
{
    int input =0;
    do
    {
        
        menu();
        printf("Input Your Number:>");
        scanf("%d",&input);
        switch (input)
        {
        case 1:
            printf("Game Start\n");
            //Sleep(500);
            game();
            break;
        
        case 0:
            printf("EXIT...\n");
            //Sleep(1000);
            break;
        default:
            Red;//改为红色
            //Sleep(300);
            printf("Erro,Input Again\n");
            Color;// 恢复默认颜色
            //Sleep(300);
            system("cls");
            break;
        }

    } while (input);
    
    return 0;
}